using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MenuButton : MonoBehaviour
{
    // Start is called before the first frame update
    RectTransform rt;
    Transform line;
    void Start()
    {
        rt=GetComponent<RectTransform>();
        line=transform.GetChild(0);
    }
    public bool GetClickArea_pos(Vector3 pos)
    {
        float _mapWidth = rt.sizeDelta.x;
        float _mapHight = rt.sizeDelta.y;
        //目标区域锚点为居中时使用 Pivot(0.5,0.5)
        if (pos.x< (rt.position.x + _mapWidth/2) && pos.x > rt.position.x-_mapWidth/2 &&
            pos.y < rt.position.y+_mapHight/2 && pos.y > (rt.position.y - _mapHight/2))
        return true;
        else
        return false;
    }
    // Update is called once per frame
    void Update()
    {
        if(GetClickArea_pos(Input.mousePosition))
        {
            line.gameObject.SetActive(true);
        }
        else
        {
            line.gameObject.SetActive(false);
        }
    }
}
